package edu.taru.shop.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import edu.taru.shop.model.Product;




public class productHelp {
	public static List<Product> toUser(List<HashMap<String,Object>> list) {
		List<Product> users = new ArrayList<Product>();
		if(list!=null&&list.size()>0) {
			for(int i=0;i<list.size();i++) {
				Product uu=new Product();
				HashMap<String,Object> m=list.get(i);
				uu.setId(m.get("PRODUCT_ID")==null?null:m.get("PRODUCT_ID").toString());
				uu.setCode(m.get("PRODUCT_CODE")==null?null:m.get("PRODUCT_CODE").toString());
				uu.setName(m.get("PRODUCT_NAME")==null?null:m.get("PRODUCT_NAME").toString());
				uu.setPhoto(m.get("PRODUCT_PHOTO")==null?null:m.get("PRODUCT_PHOTO").toString());
				uu.setSrandard(m.get("PRODUCT_STANDARD")==null?null:m.get("PRODUCT_STANDARD").toString());
				uu.setLargerStandard(m.get("PRODUCT_LARGER_STANDARD")==null?null:m.get("PRODUCT_LARGER_STANDARD").toString());
				uu.setSmallUnit(m.get("PRODUCT_SMALL_UNIT")==null?null:m.get("PRODUCT_SMALL_UNIT").toString());
				uu.setLargerUnit(m.get("PRODUCT_LARGER_UNIT")==null?null:m.get("PRODUCT_LARGER_UNIT").toString());
				uu.setSuggestPrice(m.get("PRODUCT_SUGGEST_PRICE")==null?null:m.get("PRODUCT_SUGGEST_PRICE").toString());
				uu.setGategoryId(m.get("PRODUCT_CATEGORY_ID")==null?null:m.get("PRODUCT_CATEGORY_ID").toString());
				uu.setBrandId(m.get("PRODUCT_BRAND_ID")==null?null:m.get("PRODUCT_BRAND_ID").toString());
				uu.setIsSale(m.get("PRODUCT_IS_SALE")==null?null:m.get("PRODUCT_IS_SALE").toString());
				uu.setIsLack(m.get("PRODUCT_IS_LACK")==null?null:m.get("PRODUCT_IS_LACK").toString());
				uu.setStatus(m.get("PRODUCT_STATUS")==null?null:m.get("PRODUCT_STATUS").toString());
				uu.setOrder(m.get("PRODUCT_ORDER"	)==null?null:m.get("PRODUCT_ORDER"	).toString());
				uu.setDateTime(m.get("PRODUCT_DATE_TIME")==null?null:m.get("PRODUCT_DATE_TIME").toString());
				users.add(uu);
			}
		}
		return users;
	}
}
